// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
import { TableListItem } from './data';

/** 获取规则列表 GET /api/rule */
export async function getTalentList(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/talent/list', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}


export async function getTalentDetail(
  params: {
    // query
    id: number;
  },
) {
  return request<{
    data: TableListItem[];
  }>('/api/talent/detail', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}


export async function checkTalent(
  params: {
    // query
    id: string;
    state: number;
    response?: string,
  },
) {
  return request('/api/talent/check', {
    method: 'POST',
    data: params
  });
}

export async function exportExcel(
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/talent/export', {
    method: 'GET',
  });
}

export async function getPublicTime() {
  return request<{
    code: string
    data: {
      startTime: number, 
      endTime: number,
      state: boolean
    };
  }>('/api/form/getFormState', {
    method: 'GET',
  });
}

export async function publicForm(params: {startTime?: number, endTime?: number, state: boolean}) {
  return request<{
    code: '200'
    data: {
      startTime: number, 
      endTime: number,
      state: boolean
    };
  }>('/api/form/changeFormState', {
    data: params,
    method: 'POST',
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/rule', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/rule', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
